package com.xh.login.dao;

import com.xh.login.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface UserDao {
//    @Select("insert into  () values (); ")

    /**
     * 注册用户
     * @param user user
     * @return Integer
     */
    @Insert("insert into sync_login.user (username, password, email) values (#{username},#{password},#{email})")
    Integer register(User user);

    /**
     * 登录
     * @param user user
     * @return User对象
     */
    @Select("select * from sync_login.user where username=#{username} and password=#{password}")
    User login(User user);

    @Select("select * from sync_login.user")
    List<User> index();

    @Insert("insert into sync_login.user (username, password, email)VALUES(#{username},#{password},#{email})")
    Integer addUser(User user);
    @Delete("delete from sync_login.user where id=#{id} ;")
    Integer deleteUser(Integer id);
    @Update("update sync_login.user set username=#{username},password=#{password} where id=#{id}")
    Integer updateUser(User user);
}
